import requests
import  time
from conf.api_path import ApiPath
from tools.request_post import request_mode


def login():
  # 实例属性
  # 登录接口url
  login_url = "http://iot.giantsound.cn/gst/broadcast/cms/login"
  # 请求头
  headers = {
    'Content-Type': 'application/json;charset=UTF-8',
    'Accept': 'application/json, text/plain, */*'
  }
  payload = "{\n\t\"requestData\": {\n\t\t\"userName\": \"admin\",\n\t\t\"password\": \"Gs2021!\"\n\t}\n}"
  response = requests.request("POST", login_url, headers=headers, data=payload)
  token = response.json()['data']['token']
  # 将token添加到请求头中，用于其他接口的鉴权
  headers["Authorization"] = "Bearer {}".format(token)
  print("输出:", headers, type(headers))




if __name__ == '__main__':
  login = login()




